﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

using Tunneler.Tools;

namespace Tunneler {
    class Artefact : IGameObject {
        static Texture2D texture;
        Color[] textureData;

        Vector2 origin;

        public float Rotation { get { return 0f; } }
        public Vector2 Position { get; set; }
        public float TextureScale { get { return 0.5f; } }
        public Vector2 Origin { get { return origin; } }
        public Texture2D Texture { get { return texture; } }
        public Color[] TextureData { get { return textureData; } }

        public Artefact() {
        }

        public Artefact(Vector2 position) {
            Position = position;
        }

        public void Update(GameTime gameTime) {
            // No effect
        }

        public void LoadContent(ContentManager content) {
            texture = content.Load<Texture2D>("artefact");
            textureData = new Color[texture.Width * texture.Height];
            texture.GetData<Color>(textureData);
            origin = new Vector2(texture.Width / 2, texture.Height / 2);
        }

        public void Draw(SpriteBatch spriteBatch) {
            spriteBatch.Draw(Texture, Position, null, Color.White, Rotation, Origin, TextureScale, SpriteEffects.None, 0);
        }

        public void TouchedBy(Terrain terrain) {
            // No effect
        }

        public void TouchedBy(IGameObject gameObject) {
            if (gameObject is Player) {
                KillSelf();
            } else if (gameObject is PlayerBase) {
                KillSelf();
            } else if (gameObject is LaserShot) {
            }
        }

        private void KillSelf() {
            World.Instance.DeleteGameObject(this);
        }
    }
}
